<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>当前计数：{{count}}</h1>
        <button v-on:click="add">+</button>
        <button v-on:click="sub">-</buttonv-on:click="count = count + 1">
    </div>
    <script src="vue.js"></script>
    <script>
        app = new Vue({
            //声明要绑定的id
            el:'#app',  
            //数据对象 
            data:{
                count:0
            },
            //methods用于定义方法
            methods: {
                add:function(){
                    //当前对象内需要加this
                    this.count = this.count + 1
                },
                sub:function(){
                    //当前对象内需要加this
                    this.count = this.count - 1
                }
            }
        })
    </script>
</body>
</html>